feat(container-runner): jitter idle timeout to avoid teardown waves - #5595
Conversation
|
Stack for rivet-dev/actors
Get stack: change wxwlxowm |
ReviewSmall, focused change: jitters the idle-sleep timer so co-started instances do not tear down in lockstep. Logic is sound (jitter only added, never subtracted; capped at min(20%, 60s); zero-base guarded). One thing worth fixing before merge, plus a couple of minor suggestions. Blocking syscall I/O on the async runtime
The workspace already depends on Practically the impact here is small (this is a one-shot timer per actor start, not a hot path, and /dev/urandom reads are fast), but it is an easy fix that also removes the hardcoded Linux-only path. Missing test coverage No test covers idle_timeout_with_jitter / random_duration_up_to bounds behavior (jitter never subtracts, capped at min(20%, 60s), zero-jitter fallback on RNG failure). Per CLAUDE.md, Rust tests belong under container-runner/tests/, not inline #[cfg(test)]. These are pure functions, cheap to test directly (e.g. assert idle_timeout_with_jitter(base) >= base across a range of base values, and that the cap holds for large base). Minor The silent fallback to Duration::ZERO when /dev/urandom cannot be opened/read is a reasonable fail-open choice, but it is silent, with no log line. If this ever happened fleet-wide (e.g. a sandboxed environment without /dev/urandom), jitter would silently stop working with no signal in the logs. Not blocking, just a visibility gap. Overall a well-scoped fix for the stated problem (teardown waves); the main ask is to swap the hand-rolled /dev/urandom read for rand::thread_rng() so the RNG call is not a blocking syscall on the async path. |
c320933 to
ddf4aad
Compare
892453d to
8617b0f
Compare
No description provided.